package com.touhou.youmu.config

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import springfox.documentation.swagger2.annotations.EnableSwagger2
import java.time.LocalDate
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.service.ApiInfo
import java.util.*
import springfox.documentation.builders.ApiInfoBuilder
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter

/**
 * api 文档访问路径
 *  @url(http://localhost:8340/swagger-ui.html)
 */
@Configuration
@EnableSwagger2
class ApiDocConfig  {


    @Bean
    fun createRestApi(): Docket {
        return Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.touhou.youmu"))
                .paths(PathSelectors.any())
                .build()
    }
    private fun apiInfo(): ApiInfo {
        return ApiInfoBuilder()
                .title("youmu API 文档")
                .description("项目描述")
//                .termsOfServiceUrl("https://hj.canmou123.com/")
//                .contact("dreamhj")
                .version("1.0")
                .build()
    }
}